<?php

namespace app\admin\controller\api;

use app\admin\library\DistinguishAddress;
use app\common\model;

/**
 * 系统
 * @internal
 */
class System extends Api
{
    protected $noNeedLogin = ['index'];
    protected $noNeedRight = ['*'];

    public function _initialize()
    {
        parent::_initialize();
    }

    /**
     * 系统列表
     *
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function index()
    {
        $list = model\System::where('debug', 0)->field('id,title,url,logo,target')->select();

        foreach ($list as $key => $value) {
            if (!strstr($value->logo, 'http')) {
                $value->logo = config('app_url') . $value->logo;
            }
        }
        $this->success('', $list);
    }

}